s = input()
# 最长回文子序列
n = len(s)
dp = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for i in range(n, 0, -1):
    for j in range(i, n + 1):
        if s[i - 1] == s[j - 1]:
            if i + 1 <= n and j - 1 > 0:
                dp[i][j] = dp[i + 1][j - 1] + 2
        else:
            if i + 1 <= n and j - 1 > 0:
                dp[i][j] = max(dp[i + 1][j - 1], dp[i][j])
            if i + 1 <= n:
                dp[i][j] = max(dp[i][j], dp[i + 1][j])
            if j - 1 > 0:
                dp[i][j] = max(dp[i][j], dp[i][j - 1])
print()
